﻿namespace Bread.Utility;

public struct PointD
{
    public double X;

    public double Y;

    public PointD(double x, double y)
    {
        X = x;
        Y = y;
    }
}

public struct PointN
{
    public int X;

    public int Y;

    public PointN(int x, int y)
    {
        X = x;
        Y = y;
    }
}

public static class PointHelper
{
    public static void FillTo(this List<double> list, PointD[] points)
    {
        list.Clear();
        foreach (var p in points) {
            list.Add(p.X);
            list.Add(p.Y);
        }
    }

    public static PointD[] ToPoints(this List<double> list)
    {
        var count = list.Count / 2;
        var ps = new PointD[count];
        if (count == 0) return ps;
        for (int i = 0; i < count; i++) {
            ps[i] = new PointD(list[i * 2], list[i * 2 + 1]);
        }
        return ps;
    }
}